NPC = {}
NPCs = {}
	
NPC.__index = NPC

NPC.MobID = 0
NPC.Name = ""
NPC.EngageSounds = {}
NPC.AttackSounds = {}
NPC.SwingSounds = {}
NPC.DeathSounds = {}
NPC.SpawnSounds = {}
NPC.MinDamage = 10
NPC.MaxDamage = 20
NPC.AttackSpeed = 1.2
NPC.Vendor = false
NPC.RandomName = false
NPC.Aggressive = false
NPC.Defensive = false
NPC.MatchMaker = false
NPC.SpellCaster = false
NPC.Healer = false
NPC.IdleAnim = ACT_HL2MP_IDLE_MELEE2
NPC.RunAnim = ACT_HL2MP_RUN_MELEE2
NPC.AttackAnim = ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE2 
NPC.Faction = 0
NPC.HealthMax = 1
NPC.MainWeapon = ""
NPC.OffWeapon = ""
NPC.Scale = 1.2
NPC.Position = Vector(0, 0, 0)
NPC.Speed = 150
NPC.Gear = {}


print("Acquiring NPCs...")

local _R = debug.getregistry( )
	_R.Npc = NPC
local n, m

local curindex = 1

function NPC:SpellThink( ent )
end

function NPC:ApplyToEnt( ent )
	ent.Faction = self.Faction
	ent.HealthMax = self.HealthMax
	ent.Health = self.HealthMax
	ent.Aggressive = self.Aggressive
	ent.AggroRadius = self.AggroRadius or 256
	ent.Defensive = self.Defensive
	ent.Vendor = self.Vendor
	ent.MinDamage = self.MinDamage
	ent.MaxDamage = self.MaxDamage
	ent.AttackSpeed = self.AttackSpeed
	ent.AttackDelay = self.AttackDelay
	ent.Speed = self.Speed
	ent.Scale = self.Scale
	ent.Gear = self.Gear
	ent.Model = self.Model
	ent.RandomName = self.RandomName
	ent.IdleAnim = self.IdleAnim
	ent.RunAnim = self.RunAnim
	ent.WalkAnim = self.WalkAnim
	ent.AttackAnim = self.AttackAnim
	ent.MatchMaker = self.MatchMaker
	ent.SpellCaster = self.SpellCaster
	ent.MobID = self.MobID
	ent.Wander = self.Wander
	
	if(#self.AttackSounds > 0)then
		ent.AttackSounds = self.AttackSounds
	end
	if(#self.EngageSounds > 0)then
		ent.EngageSounds = self.EngageSounds
	end
	if(#self.SwingSounds > 0)then
		ent.SwingSounds = self.SwingSounds
	end
	if(#self.SpawnSounds > 0)then
		ent.SpawnSounds = self.SpawnSounds
	end
	if(#self.DeathSounds > 0)then
		ent.DeathSounds = self.DeathSounds
	end
	if(self.MainWeapon != "")then
		ent.MainWeapon = self.MainWeapon
	end
	if(self.OffWeapon != "")then
		ent.OffWeapon = self.OffWeapon
	end
	if(self.Spells and #self.Spells > 0)then
		ent.Spells = self.Spells
	end
	ent:SetName(self.Name)
end

for n, m in ipairs( file.Find( "gamemodes/RPGDM/gamemode/npcs/*.lua", "MOD" ) ) do
	
	print( "npcs/" .. m)
	AddCSLuaFile( "npcs/" .. m )
	include( "npcs/" .. m)
		
	local NPC = table.Copy(_R.Npc)
	
	table.insert( NPCs, NPC )
		curindex = curindex + 1
end

